package com.itany.lambda;

/**
 * @Author:石小俊
 * @Date:2022/11/17 9:06
 * @Version:1.0-SNAPSHOT
 * @Description:
 */
public class Test {

    public static void main(String[] args) {
        // JDK8之前的匿名内部类用法
        SomeInterface someInterface = new SomeInterface() {
            @Override
            public String doSome(String s1, String s2) {
                System.out.println("s1:"+s1+",s2:"+s2);
                return s1+s2;
            }
        };
        someInterface.doSome("admin","alice");

        // Lambda表达式
        SomeInterface someInterface2 =  (s1, s2) -> {
            System.out.println("s1:"+s1+",s2:"+s2);
            return s1+s2;
        };

        // JDK8之前的匿名内部类用法
        SomeInterface2 someInterface21 = new SomeInterface2() {
            @Override
            public void doSome(String s) {
                System.out.println(s);
            }
        };

        // Lambda表达式用法
        SomeInterface2 someInterface22 = s -> System.out.println(s);

        // JDK8之前的匿名内部类用法
        SomeInterface3 someInterface31 = new SomeInterface3() {
            @Override
            public String doSome() {
                return "doSome";
            }
        };

        // Lambda表达式用法
        SomeInterface3 someInterface32 = () -> "doSome";

    }

}
